
#include "tp2.h"


void sierpinski_c    (
	unsigned char *src,
	unsigned char *dst,
	int cols,
	int filas,
	int src_row_size,
	int dst_row_size)
{
	unsigned char (*src_matrix)[src_row_size] = (unsigned char (*)[src_row_size]) src;
	unsigned char (*dst_matrix)[dst_row_size] = (unsigned char (*)[dst_row_size]) dst;

	int i,j;
	for(i=0;i<filas;i++)	
	{
		for(j=0;j<cols;j++)
		{
			bgra_t* p_s = (bgra_t*)&src_matrix[i][j*4];
                        bgra_t* p_d = (bgra_t*)&dst_matrix[i][j*4];
 	
			float frac_1=(((float)i)/filas)*255.0;
			float frac_2=(((float)j)/cols)*255.0;
			float coefi=((int)frac_1)^((int)frac_2);
			float coef= ((float)coefi)/255.0;

			p_d->a=p_s->a;	
			p_d->b=p_s->b*coef;	
			p_d->g=p_s->g*coef;
			p_d->r=p_s->r*coef;

		}

	}

}


